package com.weilus.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.dataflow.rest.client.DataFlowOperations;
import org.springframework.cloud.dataflow.rest.client.DataFlowTemplate;
import org.springframework.cloud.dataflow.rest.resource.about.AboutResource;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
public class App {
    public static void main(String[] args) {
        SpringApplication.run(App.class,args);
    }


    @Autowired
    DataFlowOperations dataFlowOperations;

    @Bean
    public CommandLineRunner commandLineRunner(){
        return args -> {
            AboutResource aboutResource =  dataFlowOperations.aboutOperation().get();
            System.out.println(aboutResource);
        };
    }
//    @Bean
//    public PartitionHandler partitionHandler(TaskLauncher taskLauncher, JobExplorer jobExplorer,TaskRepository taskRepository){
//        DockerResource resource = new DockerResource("guoyu.com:8443/dataflow-task");
//        DeployerPartitionHandler partitionHandler = new DeployerPartitionHandler(taskLauncher, jobExplorer, resource, "workerStep",taskRepository);
//        List<String> commandLineArgs = new ArrayList<>(3);
//        commandLineArgs.add("--spring.profiles.active=worker");
//        commandLineArgs.add("--spring.cloud.task.initialize.enable=false");
//        commandLineArgs.add("--spring.batch.initializer.enabled=false");
//        partitionHandler.setCommandLineArgsProvider(new PassThroughCommandLineArgsProvider(commandLineArgs));
//        partitionHandler.setEnvironmentVariablesProvider(new NoOpEnvironmentVariablesProvider());
//        partitionHandler.setMaxWorkers(2);
//        partitionHandler.setApplicationName("PartitionedBatchJobTask");
//        return partitionHandler;
//    }

}
